/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sadhar.sipp.pospendapatan;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.sadhar.errhandler.ClassAntiNull;
import org.sadhar.sia.common.ClassConnection;

/**
 *
 * @author hendro
 */
public class PosPendapatanDAOImpl implements PosPendapatanDAO{

    public List<PosPendapatan> list() throws Exception {
        List<PosPendapatan> list = new ArrayList<PosPendapatan>();
        List<Map> rows = ClassConnection.getJdbc().queryForList("SELECT * FROM ppmk.posPendapatan WHERE namaTabelAnggaran=?",
                new Object[]{"anggaranPendapatanLain"});
        for (Map m : rows) {
            PosPendapatan pos = new PosPendapatan();
            pos.setIdPosPendapatan(ClassAntiNull.AntiNullInt(m.get("idPosPendapatan")));
            pos.setNamaPosPendapatan(ClassAntiNull.AntiNullString(m.get("posPendapatan")));
            pos.setIsLainLain(ClassAntiNull.AntiNullString(m.get("isLainLain")));
            pos.setNamaTabelAnggaran(ClassAntiNull.AntiNullString(m.get("namaTabelAnggaran")));
            pos.setKodeGL(ClassAntiNull.AntiNullString(m.get("kodeGL")));
            pos.setIsMutlak(ClassAntiNull.AntiNullString(m.get("isMutlak")));
            list.add(pos);
        }
        return list;
    }

    public void insert(PosPendapatan pos) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void delete(PosPendapatan pos) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void update(PosPendapatan pos) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public List<PosPendapatan> listAll(String keySearch) throws Exception {
        List<PosPendapatan> list = new ArrayList<PosPendapatan>();
        List<Map> rows = ClassConnection.getJdbc().queryForList("SELECT * FROM ppmk.posPendapatan WHERE namaTabelAnggaran='anggaranPendapatanLain' AND posPendapatan LIKE ?",new Object[]{
            "%"+keySearch+"%"
        });
        for (Map m : rows) {
            PosPendapatan pos = new PosPendapatan();
            pos.setIdPosPendapatan(ClassAntiNull.AntiNullInt(m.get("idPosPendapatan")));
            pos.setNamaPosPendapatan(ClassAntiNull.AntiNullString(m.get("posPendapatan")));
            pos.setIsLainLain(ClassAntiNull.AntiNullString(m.get("isLainLain")));
            pos.setNamaTabelAnggaran(ClassAntiNull.AntiNullString(m.get("namaTabelAnggaran")));
            pos.setKodeGL(ClassAntiNull.AntiNullString(m.get("kodeGL")));
            pos.setIsMutlak(ClassAntiNull.AntiNullString(m.get("isMutlak")));
            list.add(pos);
        }
        return list;
    }

}
